#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
'''
t1 = [(1, '192.168.1.100'), (2, '192.168.1.101'), (3, '192.168.1.2'), (4, '192.168.1.3')]
# print(sorted(t1, key=lambda x:x[1]))
L = [('A', 1500), ('B', 230), ('C', 362)]
t2 = ['192.168.1.100', '192.168.1.101', '192.168.1.2', '192.168.1.3']

# for i in t1:
#     print(i[1])
print(sorted(L, key=lambda l1: l1[1]))
print(sorted(t1, key=lambda t2: t2[1]))
print(sorted(t2, reverse=True))

t3 = ['192.168.1.33', '10.5.2.4', '10.5.1.3', '202.98.96.68', '133.120.1.1', '192.168.1.22']
print(sorted(t3, key=lambda x: (int(x.split('.')[0]), int(x.split('.')[1]), int(x.split('.')[2]))))

print(sorted(t1, key=lambda x: (
int(x[1].split('.')[0]), int(x[1].split('.')[1]), int(x[1].split('.')[2]), int(x[1].split('.')[3]))))

data = {'code': 10000, 'msg': '删除成功', 'data': [
    [(1, '192.168.1.100'), (2, '192.168.1.101'), (3, '192.168.1.2'), (4, '192.168.1.3'), (5, '192.168.9.11'),
     (6, '192.168.9.12'), (7, '192.168.9.13'), (8, '192.168.9.15'), (10, '192.168.9.16'), (11, '192.168.9.19'),
     (9, '192.168.9.22'), (12, '192.168.9.23')]]}

for i in data['data']:
    for x in i:
        print(x[0], x[1])

'''
#
# xxxx = "sdf"
#
# print("%s" %xxxx)


# a={'serialnumber': '', 'inport': '', 'outport': 'a1a', 'sequenceid': 'aaaaa', 'protocols': 'TCP', 'inaddress': '1', 'outaddress': '1'}
# xx = True if all([v for k,v in a.items()]) else False
# print(xx)
# print([v for k,v in a.items()])
# if all([v for k,v in a.items()]):
#     print('空')
# else:
#     print('非空')

# xx = {'input': {'serialnumber': '', 'inport': '', 'sequenceid': ''}, 'select': {'outaddress': '1'}}

# aaa = {}
# for k in xx.keys():
#     for x, y in xx[k].items():
#         aaa[x] = y
# print(aaa)

# bbb = {'serialnumber': '2', 'inport': '101', 'outport': '101', 'sequenceid': '1000', 'protocols': 'TCP',
#        'inaddress': '1', 'outaddress': '1'}
#
# for k,v in bbb.items():
#     print()
# xxx = 'insert into test {0} value {1}'.format(kkkk, tuple(v for v in bbb.values()))
# print(xxx)
# ccc = tuple(k for k, v in bbb.items())
# print(ccc)
#
# a="1'1"
# print(a.replace("'",""))
# getValue = ['', '', '', '', 'TCP', '1', '1', '1']
# print(all([getValue,]))
# get2 = [(1, 'TCP', 1, 100, 1, 100, 1, 100, 1),()]
# print(all(get2))

# t10 = {'serialnumber': None, 'sequenceid': None}
# # print(all([{"id":"","name":"" }]))
# print(all([i for i in t10.values()]))
# print([i for i in t10.values()])
# print(all([1,2]))

# xx = {'serialnumber': '', 'sequenceid': '111'}
# x1 = [v for k,v in xx.items()]
# x2 = {'serialnumber': 'serialnumber已存在', 'sequenceid': 'sequenceid已存在'}
# x3 = [True for i in x2.items() if i is not None False]
# print(x3)
# x4 = {'serialnumber': '' }
# if not x4:
#     print("空的字典")
# else:
#     print("不是空的字典")


# 验证码
import random

# 大写 A-Z
print(chr(random.randrange(65,90)))
# 小写 a-z
print(chr(random.randrange(97,122)))

print(random.choice([chr(random.randrange(97,122)), random.randint(0,9), chr(random.randrange(65,90))]))

x=[random.choice([chr(random.randrange(97,122)), str(random.randint(0,9)), chr(random.randrange(65,90))]) for i in range(4)]
x=''.join([random.choice([chr(random.randrange(97,122)), str(random.randint(0,9)), chr(random.randrange(65,90))]) for i in range(4)])
# y="".join(x)
# print(y)
# print(x)

# 生成一个元组
print(tuple([random.randint(0,255) for i in range(3)]))